#ifndef BOOL
#define BOOL

#include "math.h"
#include "polygon.h"

enum BL_Op{ SUBTRACT_A_B, SUBTRACT_B_A, UNION, INTERSECT};
enum BL_Set{ A=0, B};
enum itype{ENEX, EXEN, EN, EX, NOTYPE=0, INVALID};

typedef struct BL_Poly{
	polygon pl;
	int rel;
	int hole;
	enum BL_Set set;
	int has_entry;
}*bpoly;

typedef struct BL_Node{
	struct Vec co;
	int flags;
	struct BL_Node *nxt, *prv, *isx;
	struct BL_Poly *pl;
	enum itype t;
	int entry;
}*bnode;

struct BL_Graph{
	struct BL_Node *nodes;
	unsigned int last, size;
	struct BL_Poly *polys;
	struct BL_Poly *pl_a;
	struct BL_Poly *pl_b;
	unsigned int pl_num;
	unsigned int inum;
};

struct BL_Graph*
bl_build_graph(const polygon pl_a, const polygon pl_b);

polylist
bl_operation(struct BL_Graph *g, const enum BL_Op op);

void
bl_kill_graph(struct BL_Graph* g);

#endif
